package top.jamsee.interceptor;

import org.springframework.http.HttpCookie;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;

public class MyInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        Cookie cks[]=request.getCookies();
//        //如果不存在username和password的cookie就拦截
//        boolean res=false;
//        for (Cookie ck:cks){
//            System.out.println(ck.getName());
//            if((ck.getName()).equals("username")||(ck.getName()).equals("password")){
//                System.out.println("xxx");
//                res=true;
//            }
//
//        }
//       if (res==false){
//           request.getRequestDispatcher("/WEB-INF/view/noLogin.html").forward(request,response);
//       }
//




        return true;
    }

}
